use std::any::Any;
use std::fmt::Display;

fn main() {
    log(&"hello");
}

fn log<T: Any + Display>(value: &T) {
    let value = value as &dyn Any;
    if let Some(str) = value.downcast_ref::<String>() {
        println!("this is string value: {}", str);
    } else if let Some(&str) = value.downcast_ref::<&str>() {
        println!("this is str value: {}", str);
    } else {
        println!("{:?}", value);
    }
}